function [XG,WG] = gauss_1D(h,n,a,b)
A=a:(b-a)/h:b;
XG=[];
WG=[];
for i=1:h
    [wg,xg] = gauss_test(n,A(i),A(i+1));
    XG=cat(1,XG,xg');
    WG=cat(1,WG,wg');
end
end
function [wg,xg] = gauss_test(n,a,b)
switch n
    case 2
        xi=[-0.5773502691896257 0.5773502691896257];
        wi=[1 1];
    case 3
        wi=[0.888888889 0.555555556 0.555555556];
        xi=[0 -0.774596669 0.774596669];
    case 4
        wi=[	0.652145155	0.652145155	0.347854845	0.347854845	];
        xi=[	-0.339981044	0.339981044	-0.861136312	0.861136312	];
    case 5
        wi=[0.568888889	0.47862867 0.47862867 0.236926885 0.236926885];
        xi=[0 -0.53846931 0.53846931 -0.906179846 0.906179846];
    case 6
        wi=[	0.360761573	0.360761573	0.467913935	0.467913935	0.171324492	0.171324492	];
        xi=[	0.661209386	-0.661209386	-0.238619186	0.238619186	-0.932469514	0.932469514	];
    case 7
        wi=[	0.417959184	0.381830051	0.381830051	0.279705391	0.279705391	0.129484966	0.129484966	];
        xi=[	0	0.405845151	-0.405845151	-0.741531186	0.741531186	-0.949107912	0.949107912	];
    case 8
        wi=[	0.362683783	0.362683783	0.313706646	0.313706646	0.222381034	0.222381034	0.101228536	0.101228536	];
        xi=[	-0.183434642	0.183434642	-0.52553241	0.52553241	-0.796666477	0.796666477	-0.960289856	0.960289856	];
    case 9
        xi=[0 -0.836031107 0.836031107 -0.96816024 0.96816024 -0.324253423 0.324253423 -0.613371433 0.613371433];
        wi=[0.330239355 0.180648161 0.180648161 0.081274388 0.081274388 0.312347077 0.312347077 0.260610696 0.260610696];
    case 10
        wi=[	0.295524225	0.295524225	0.269266719	0.269266719	0.219086363	0.219086363	0.149451349	0.149451349	0.066671344	0.066671344	];
        xi=[	-0.148874339	0.148874339	-0.433395394	0.433395394	-0.679409568	0.679409568	-0.865063367	0.865063367	-0.973906529	0.973906529	];
    case 11
        wi=[	0.272925087	0.262804545	0.262804545	0.233193765	0.233193765	0.186290211	0.186290211	0.125580369	0.125580369	0.055668567	0.055668567	];
        xi=[	0	-0.269543156	0.269543156	-0.519096129	0.519096129	-0.730152006	0.730152006	-0.8870626	0.8870626	-0.978228658	0.978228658	];
    case 12
        wi=[	0.249147046	0.249147046	0.233492537	0.233492537	0.203167427	0.203167427	0.160078329	0.160078329	0.106939326	0.106939326	0.047175336	0.047175336	];
        xi=[	-0.125233409	0.125233409	-0.367831499	0.367831499	-0.587317954	0.587317954	-0.769902674	0.769902674	-0.904117256	0.904117256	-0.981560634	0.981560634	];
    case 13
        wi=[	0.232551553	0.22628318	0.22628318	0.207816048	0.207816048	0.178145981	0.178145981	0.13887351	0.13887351	0.0921215	0.0921215	0.040484005	0.040484005	];
        xi=[	0	-0.230458316	0.230458316	-0.448492751	0.448492751	-0.642349339	0.642349339	-0.801578091	0.801578091	-0.917598399	0.917598399	-0.984183055	0.984183055	];
end
xg=((b-a)/2)*xi+((b+a)/2);
wg=((b-a)/2)*wi;
end

